/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import dm.jdbc.desc.ParameterDesc;
/*     */ import dm.sql.DmdbIntervalDT;
/*     */ import java.sql.SQLException;
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmIntvDTBinder
/*     */   extends DmBinder
/*     */ {
/*     */   private boolean exactType;
/*     */   
/*     */   public DmIntvDTBinder(DmdbPreparedStatement_bs pstmt)
/*     */   {
/*  19 */     super(pstmt);
/*     */   }
/*     */   
/*     */   void init()
/*     */   {
/*  24 */     this.recDType = 21;
/*  25 */     this.recPrec = 0;
/*  26 */     this.recScale = 0;
/*     */   }
/*     */   
/*     */   void checkType(int icol, boolean forBatch) throws SQLException
/*     */   {
/*  31 */     if (this.m_checkType) {
/*  32 */       return;
/*     */     }
/*  34 */     this.m_checkType = true;
/*     */     
/*  36 */     if (this.paramsDesc == null) {
/*  37 */       this.paramsDesc = this.pstmt.getParamsDesc();
/*     */     }
/*  39 */     byte typeFlag = this.paramsDesc[icol].getTypeFlag();
/*  40 */     int dType = this.paramsDesc[icol].getDType();
/*  41 */     int prec = this.paramsDesc[icol].getPrec();
/*  42 */     int scale = this.paramsDesc[icol].getScale();
/*  43 */     byte ioType = this.paramsDesc[icol].getIOType();
/*     */     
/*  45 */     if ((ioType != 1) && (typeFlag != 1))
/*     */     {
/*  47 */       this.destDType = this.recDType;
/*  48 */       this.destPrec = this.recPrec;
/*  49 */       this.destScale = scale;
/*  50 */       this.exactType = false;
/*     */     }
/*     */     else
/*     */     {
/*  54 */       this.destDType = dType;
/*  55 */       this.destPrec = prec;
/*  56 */       this.destScale = scale;
/*  57 */       this.exactType = true;
/*     */     }
/*     */     
/*  60 */     this.destIoType = ioType;
/*  61 */     this.srcScale = scale;
/*     */   }
/*     */   
/*     */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*     */   {
/*  66 */     DmdbIntervalDT dt = ((DmdbIntervalDT[])this.pstmt.m_paramObjects[icol])[irow];
/*  67 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/*  68 */     int scale = this.destScale;
/*  69 */     if (!this.exactType)
/*     */     {
/*  71 */       scale = dt.getPrecForSvr();
/*     */     }
/*  73 */     byte[] ret = toDbBytes(dt, this.destDType, this.destPrec, scale, serverEncoding);
/*     */     
/*  75 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*     */   }
/*     */   
/*     */   public static byte[] toDbBytes(DmdbIntervalDT dt, int destDType, int destPrec, int scale, String serverEncoding)
/*     */     throws SQLException
/*     */   {
/*  81 */     byte[] ret = null;
/*     */     
/*  83 */     switch (destDType)
/*     */     {
/*     */     case 21: 
/*  86 */       ret = Convertion.InterDtToByteArray(dt, scale);
/*  87 */       break;
/*     */     
/*     */     case 0: 
/*     */     case 1: 
/*  91 */       ret = Convertion.String_char_2CType(String.valueOf(dt), destPrec, destDType, serverEncoding);
/*  92 */       break;
/*     */     
/*     */     case 2: 
/*     */     case 19: 
/*  96 */       ret = Convertion.String_varchar_2CType(String.valueOf(dt), destPrec, destDType, 
/*  97 */         serverEncoding);
/*  98 */       break;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     default: 
/* 110 */       DBError.throwSQLException(6007);
/*     */     }
/*     */     
/* 113 */     return ret;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmIntvDTBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */